package Service;

import java.util.Scanner;

public class InputManager 
{
	/**
	 * Forces the user to enter a number between the boundaries min and max, inclusively.
	 * Good to use in combination with menu offered by output manager.
	 * 
	 * @param iMin The lower bound
	 * @param iMax The upper bound
	 * @return
	 */
	public static int readInput(int iMin, int iMax)
	{
		String response = "";
		int choice = 0;
		boolean inputOk = false;
		Scanner kb = new Scanner(System.in);
		
		while (!inputOk)
		{
			OutputManager.print("Enter your choice number between " + iMin + " and " + iMax + ": ");
			response = kb.nextLine();
			for (int i = iMin; i <= iMax; ++i)
			{
				if (String.format("%d", i).equals(response))
				{
					inputOk = true;
					choice = i;
					break;
				}
			}
		}
		return choice;
	}
}
